/*
 * @Author: your name
 * @Date: 2020-11-06 15:44:55
 * @LastEditTime: 2021-06-01 16:39:45
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \zcz\ws-shop\src\store\getters.js
 */
export default {
  totalMoney ({ cart }) {
    return cart.reduce((money, shop) => {
      if (shop.check && shop.id) {
        money += shop.price * shop.count
      }
      return money
    }, 0)
  },
  isAllCheck ({ cart }) {
    return cart.length === 0 ? false : cart.every(shop => shop.check)
  },
  totalCount ({ cart }) {
    return cart.reduce((count, shop) => {
      return count + shop.count
    }, 0)
  },
  checkCount ({ cart }) {
    return cart.reduce((count, shop) => {
      if (shop.check) {
        count += shop.count
      }
      return count
    }, 0)
  }
}
